package cn.taketoday.live;

import java.io.Serializable;

import cn.taketoday.live.data.JsonSequence;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
public class WebSocketMessage implements Serializable, JsonSequence {
  private static final long serialVersionUID = 1L;
  private String cmd;
  private Integer status;
  private Object data;

  public WebSocketMessage(String cmd) {
    this.cmd = cmd;
  }

  // static

  public static WebSocketMessage ofCommand(String cmd) {
    return new WebSocketMessage(cmd);
  }

  public static WebSocketMessage of(String cmd, Object result) {
    WebSocketMessage webSocketMessage = new WebSocketMessage(cmd);
    webSocketMessage.setData(result);
    return webSocketMessage;
  }

}
